package com.ssm.service;

import com.ssm.entity.Customer;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Random;

public class Test {
    @Autowired
    public CustomerService cs;
    public static void main(String[] args) {

        Test t = new Test();
        System.out.println(t.cs);
        Customer c;
        int j=0;
        for(int i=1;i<=100;i++){
            j=(j+1)%4;
            c = t.getCustomer(j);
            System.out.println(t.cs.insertCustomer(c));
        }

    }
    public Customer getCustomer(int i){
        Customer c=new Customer();
        switch (i){
            case 0:
                c.setC_name("王剑人"+i);
                c.setC_sex("男");
                c.setC_address("青州");
                c.setC_position("战士");
                break;
            case 1:
                c.setC_name("小夏"+i);
                c.setC_sex("男");
                c.setC_address("九州");
                c.setC_position("道士");
                break;
            case 2:
                c.setC_name("唐轻笑"+i);
                c.setC_sex("男");
                c.setC_address("蜀州");
                c.setC_position("剑客");
                break;
            case 3:
                c.setC_name("明月"+i);
                c.setC_sex("女");
                c.setC_address("云州");
                c.setC_position("魔道");
                break;
            default:
                c.setC_name("蛇道人"+i);
                c.setC_sex("男");
                c.setC_address("九州");
                c.setC_position("魔道");
        }
        c.setC_phone(getPhone());
        return c;
    }
    public String getPhone(){
        Random r = new Random();
        String phone ="1324226";
        for(int i=0;i<4;i++){
            phone =phone+r.nextInt(10);
        }
        return phone;
    }
}
